//package com.mti.jwt;
//
//import com.alibaba.fastjson.JSONObject;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.http.MediaType;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.http.server.reactive.ServerHttpResponse;
//import org.springframework.web.server.ServerWebExchange;
//import org.springframework.web.server.WebFilter;
//import org.springframework.web.server.WebFilterChain;
//import reactor.core.publisher.Mono;
//
//import java.util.Set;
//
//@Configuration
//public class JwtWebConfig implements WebFilter {
//
//    @Autowired
//    private StringRedisTemplate redisTemplate;
//
//    @Override
//    public Mono<Void> filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) {
//        ServerHttpRequest request=  serverWebExchange.getRequest();
//
////        System.out.println("request=login=>" + request.getPath().value().contains("login"));
////        System.out.println("request=swagger-ui=>" + request.getPath().value().contains("/swagger-ui.html#"));
//
////        if(request.getPath().value().contains("login")
////                || request.getPath().value().contains("swagger")
////                || request.getPath().value().contains("springfox")
////                || request.getPath().value().contains("/v2/")){
////            return webFilterChain.filter(serverWebExchange);
////        }
//
////        ServerHttpResponse response=serverWebExchange.getResponse();
////        String token = request.getHeaders().getFirst(JwtTokenFactory.HEADER_STRING);
////        System.out.println("token==>"+token);
////
////        if(!StringUtils.isEmpty(token)) {
////           // return this.setErrorResponse(response,"不合法的请求，请验证是否登陆");
////        }
//////
////        Set<String> keys = redisTemplate.keys( "*" + token);
////        String authorization = null;
//////        if (keys.size() < 1) {
//////         //   return this.setErrorResponse(response,"不合法的请求，请验证是否登陆");
//////        }
////        for(String str : keys) {
//////            account = JSON.parseObject((String)redisTemplate.opsForValue().get(str), AccountBo.class ) ;
////            authorization = (String)redisTemplate.opsForValue().get(str) ;
////        }
////
////        System.out.println("authorization===>" + authorization);
////
//////        if (StringUtils.isEmpty(authorization)) {
//////          //  return this.setErrorResponse(response,"用户未登录或者已经过期");
//////        }
//////
//////        try {
//////         //   serverWebExchange.getAttributes().put("tokenValue", token);
//////        }catch(Exception e) {
//////          //  return this.setErrorResponse(response,e.getMessage());
//////        }
////
////        serverWebExchange.getAttributes().put("tokenValue", token);
//////        request.getQueryParams()
//        return  webFilterChain.filter(serverWebExchange);
//
//    }
//    protected Mono<Void> setErrorResponse(ServerHttpResponse response, String message){
//        response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
//        JSONObject jsonObject=new JSONObject();
//        jsonObject.put("status_code",500);
//        jsonObject.put("data",message);
//        return response.writeWith(Mono.just(response.bufferFactory().wrap(jsonObject.toString().getBytes())));
//
//    }
//}
